﻿Chenxin.UI.PrintInBillForm=Chenxin.extend(Chenxin.UI.FormCommon,{
	actionUrl:'/service/logic/PrintBill.ashx',
	id:'frm_printbillin',
    jqmWidth:800,
	jqmHeight:425,
	title:'打印预览',
	type:'jqmodel',
	defBBtn:false,
	op:'printview',
    jqmHasFoot:true,
	createBBtn:function(){
	return [{
	    text: '页面设置',
	    handler: this.settingPring
	}, {
			text:'打印',
			handler:this.printForm
		},{
			text:'关闭',
			handler:this.hide,
			scope: this
		}]	
	},
	fitData:function(model){
		curModel = model;
		model=model||{};
		Chenxin.Fn.BindData(model,this.id);
},
settingPring: function() {
    document.all.WebBrowser.ExecWB(8, 1);
},
    createForm: function() {
        return Chenxin.FormCommon.billInForm(this.id);
    },
	printForm:function(){
		var _curForm = this;
		//保存打印信息
		Chenxin.ajax({
			type: "get",
            dataType: "json",
            url: "/service/logic/PrintBill.ashx",
            data: { op: 'saveprint', billId: curModel.BillId, billCode:curModel.BillCode },
            onSuccess: function(data) {
				var prtContent = $("#frm_printbillin").find(".x-win-body").html();
				var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0,menubar=0');
				WinPrint.document.write(prtContent);
				WinPrint.document.close();
				WinPrint.focus();
				WinPrint.print();
				WinPrint.close();
            }
        });
	},
	reset:function(){
		this.fitData({});
	},
	initComponent:function(){
		Chenxin.UI.PrintInBillForm.superclass.initComponent.call(this);
	}
});

Chenxin.FormCommon.billInForm=function(formId){// height:100px;overflow:auto;
return '<div style="font-family:Tahoma, Geneva, sans-serif;font-size:14px; height:465px; margin:auto; width:704px;"><h1 style="color:#000; font-size:28px; font-weight:bolder;text-align:center;">收款单</h1><div style="float:left; height:350px; width:92%;"><div style="height:45px; line-height:45px;"><span style="display:block; float:right;  width:33%;"> 开单号：<span id="' + formId + 'BillCode"></span></span><span style=" display:block; float:right; width:37%;">开单日期：<span id="' + formId + 'BillDate"></span></span></div><table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none;"><tr><td width="14%" height="42" align="center" style="border:solid #000 1px;">合同编号</td><td width="36%" style="padding-left:10px;border:solid #000 1px;"><span id="' + formId + 'ContractCode"></span></td><td width="14%"  align="center" style="border:solid #000 1px; padding-left:10px;">合同标的</td><td width="36%" style="padding-left:10px;border:solid #000 1px;"><span id="' + formId + 'BargainPrice"></span>元</td></tr><tr><td height="42"  align="center" style="border:solid #000 1px;">客户姓名</td><td style="border:solid #000 1px;padding-left:10px;"><span id="' + formId + 'CustomerName"></span></td><td  align="center" style="border:solid #000 1px;">客户性质</td><td style="border:solid #000 1px;padding-left:10px;"><span id="' + formId + 'CustomerType"></span></td></tr><tr><td height="42"  align="center" style="border:solid #000 1px;">房屋地址</td><td colspan="3" style="border:solid #000 1px;padding-left:10px;"><span id="' + formId + 'HouseAddress"></span></td></tr><tr><td rowspan="2"  align="center" style="border:solid #000 1px;"><span id="' + formId + 'FundName"></span></td><td height="42" colspan="3" style="border:solid #000 1px;padding-left:10px;">金额（小写）：<span id="' + formId + 'BillMoney"></span>元</td></tr><tr><td height="42" colspan="3" style="border:solid #000 1px;padding-left:10px;">金额（大写）：<span id="' + formId + 'BillMoneyBig"></span></td></tr><tr><td height="42" align="center" style="border:solid #000 1px;">备注</td><td colspan="3" style="border:solid #000 1px;padding-left:10px;"><span id="' + formId + 'BillMemo"></span></td>    </tr></table><div style="margin-top:10px;height:32px; line-height:32px;"><div style=" height:32px;float:left; width:25%; overflow:hidden;">分店：<span id="' + formId + 'BillDepartNameL"></span></div><div style=" height:32px;float:left; width:24%; overflow:hidden;">经纪人：<span id="' + formId + 'BillEmployeeL"></span></div><div style="float:left; width:25%;">开单员：<span id="' + formId + 'BillOprEmpName"></span></div><div style="float:left; width:26%;">打印日期：<span id="' + formId + 'PrintDate"></span></div></div><div style="margin-top:10px;height:32px; line-height:32px;"><div style="float:left; width:25%; margin-left:49%;">出纳：<span>&nbsp;</span></div><div style="float:left; width:26%;">复核：<span></span></div></div></div><div style="float:right; width:14px;layout-flow:vertical-ideographic;writing-mode=tb-rl;">第一联：交易部 第二联：财务部 第三联：分店</div></div>';
}